<?php

//根据系ID返回系名称 20120817qzr
function fs_get_departname($i)
{
	if ( $i=='' || is_null($i) || !is_numeric($i))	{return '无';break;}
	global $db;
	$sql	=	"select name from ".TABLE_DEPARTMENT." where id=$i ";
	$result =	$db -> query($sql);
	$row	=	$db -> fetch_array($result);
	return	$row['name'];
}

//根据专业ID返回专业名称 20120817qzr
function fs_get_majorname($i)
{
	if ( $i=='' || is_null($i) || !is_numeric($i))	{return '无';break;}
	global $db;
	$sql	=	"select name from ".TABLE_MAJOR." where id=$i ";
	$result =	$db -> query($sql);
	$row	=	$db -> fetch_array($result);
	return	$row['name'];
}
//根据表名 id 返回name值 qzr
function fs_get_usedname($tablename,$i)
{
	if ( $i=='' || is_null($i) || !is_numeric($i))	{return '无';break;}
	global $db;
	$sql	=	"select name from ".$tablename." where id=$i ";
	$result =	$db -> query($sql);
	$row	=	$db -> fetch_array($result);
	return	$row['name'];
}
//根据表名 字段 id 返回需要的name值 qzr
function fs_get_usingname($tablename,$field,$i,$name)
{
	if ( $i=='' || is_null($i) || !is_numeric($i))	{return '无';break;}
	global $db;
	$sql	=	"select ".$name." from ".$tablename." where ".$field." = '".$tablename."' ";
	$result =	$db -> query($sql);
	$row	=	$db -> fetch_array($result);

	return	$row['classid'];
}
//根据班级id 返回系名和专业名 qzr
function fs_get_usename($i)
{
	if ( $i=='' || is_null($i) || !is_numeric($i))	{return '无';break;}
	global $db;
	$sql	=	"select d.name as departmentname,m.name as majorname from nettteach_class c,nettteach_department d,nettteach_major m where c.id=$i and c.majorid = m.id and c.departmentid = d.id ";
        $result =	$db -> query($sql);
	$row	=	$db -> fetch_array($result);
	return	$row['departmentname']."/".$row['majorname'];
}
//根据XX表 的 id 返回系名和专业名 qzr
function fs_get_depart_major($table,$i)
{
	if ( $i=='' || is_null($i) || !is_numeric($i))	{return '无';break;}
	global $db;
	$sql	=	"select d.name as departmentname,m.name as majorname from ".$table." c,nettteach_department d,nettteach_major m where c.id=$i and c.majorid = m.id and c.departmentid = d.id ";
        $result =	$db -> query($sql);
	$row	=	$db -> fetch_array($result);
	return	$row['departmentname']."/".$row['majorname'];
}
?>
